namespace V2TEK.NET.SH.Silverlight.Calendar
{
    using System;

    public class WorkingTime
    {
        internal long _duration;
        private TimeSpan _end;
        internal long _endTime;
        private TimeSpan _start;
        internal long _startTime;

        public WorkingTime(TimeSpan startTime, TimeSpan endTime)
        {
            if (endTime == TimeSpan.Zero)
            {
                endTime = TimeSpan.FromHours(24.0);
            }
            if (startTime >= endTime)
            {
                throw new ArgumentException("startTime cannot be bigger or equal to  endTime");
            }
            if (startTime.TotalHours > 24.0)
            {
                throw new ArgumentException("startTime does not specify an hour");
            }
            if (endTime.TotalHours > 24.0)
            {
                throw new ArgumentException("endTime does not specify an hour");
            }
            this._start = startTime;
            this._end = endTime;
            this._startTime = startTime.Ticks;
            this._endTime = endTime.Ticks;
            this._duration = this._endTime - this._startTime;
        }

        public virtual object Clone()
        {
            return base.MemberwiseClone();
        }

        internal long Duration
        {
            get
            {
                return this._duration;
            }
        }

        public TimeSpan EndTime
        {
            get
            {
                return this._end;
            }
        }

        public TimeSpan StartTime
        {
            get
            {
                return this._start;
            }
        }
    }
}

